products = [["iphone", 6888], ["MacPro", 14800], ["小米6", 2499], ["Coffee", 31], ["Book", 60], ["Nike", 699]]
productdict = dict(zip(range(1, len(products) + 1), products))
shop_car = []
shop_cost = 0
print("商品ID", "商品名称", "商品价格")

for k, v in productdict.items():
    print(k, v[0], v[1], sep=' ' * 5)

shop_ID = list(productdict.keys())
# print (shop_ID)

while True:
    p = input(">>>请选择商品ID？") #todo 增加个退出程序的提示
    if p == "q":
        break
    if int(p) in shop_ID:
        shop_car.append(p)
        print("您选择了{},单价：{}".format(productdict[int(p)][0], productdict[int(p)][1]))
    else:
        print("对不起,没有您所要购买的货物")

# print (shop_car)
for i in shop_car:
    a = productdict[int(i)][1]
    shop_cost += a

print("您已退出选购")
print("*" * 30)
print("您的购买总价为：{}".format(shop_cost))

# 缺少个买后如何退出的提示